// ----------------------------------------------整体-----------------------------------

import Cookie from './cookie.js'
import Api from  './api.js'


new Vue({
    el:'#dinner',
    data:{
        id:'',                      //------当前用户id
        Uname:'',                   //------用户姓名
        NickName:'',                //------用户昵称
        Imgpath:'',                 //------用户头像路径
        search:'',                  //------搜索框内容
        Info:'',                    //个人简介
        Zy:'',                      //职业
        City:'',                    //城市
        title:'',                               //活动标题
        selected:'100',                        //活动价格
        people:'',                            //报名人数
        begin_time:'',                       //活动时间
        end_time:'',                        //截至报名时间
        RadioGroup1:'',                    //活动玩法
        checkedNames:[],                  //活动标签
        updateInfo:'',                   //修改图片的文本域
        addInfo:'',                     //添加图片的文本域
        require:'',                    //活动要求
        checked:false,                //同意协议状态
        name:'空',                      //姓名

    },
    methods:{
        initData(user) {                              //---------进行姓名、昵称、头像的赋值------------
            this.Uname = user.name
            this.NickName = user.nc
            this.Imgpath = user.tx
            this.Info = user.info
            this.Zy = user.zy
            this.City = user.city
        },
        deleteImg(){                            //删除图片功能
            $('#ImgPr').attr("src","")
        },
        revoke(){                               //取消按钮
            location.href='Release.html'
        },
        commit() {                              //提交按钮
            alert(this.begin_time)
            if(this.checked==true && this.title!='' && this.people!='' && this.begin_time!='' && this.end_time!=''){
                this.$alert('提交成功', '系统提示', {
                    confirmButtonText: '确定',
                });
            }else{
                this.$alert('没有勾选同意', '系统提示', {
                    confirmButtonText: '确定',

                });
            }

        }
    },
    mounted(){
        //-------------加载页面初始化数据--------------------------
        Cookie.setCookie("id", 1, "d1")
        this.id = Cookie.getCookie("id")                         //------访问其他页面存储的用户id
        let user = Api.login(this.id)                                  //------加载用户信息
        this.initData(user)
        //--------------------------------------------------------
    }
})


